#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n+5,0x3f3f3f3f),pre(n+5,0);
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	pre[i+1]=max(pre[i],a[i]);
    }
    for(int i=2;i<=n;i+=2){
    	a[i]=max(a[i],pre[i]);
    }

    // for(int i=1;i<=n;i++){
    // 	cout<<a[i]<<' ';
    // }
    // cout<<'\n';

    ll res=0;
    for(int i=1;i<=n;i+=2){
    	ll temp = min(a[i-1],a[i+1]);
    	if(a[i]>=temp){
    		res+=a[i]-temp+1;
    	}
    }
    cout<<res<<'\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}